﻿/*
Copyright (C) 2008, 2009 Henrik Naess

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Xml;
using MatrixPlugin.Constants;
using MatrixPlugin.Utils;

namespace MatrixPlugin
{
    internal class DefaultValues
    {
        private static readonly string i = Identation(FileUtility.Indentation);

        private static string Identation(int indentation)
        {
            string indentationString = null;
            for (int j = 0; j < indentation; j++)
            {
                indentationString += " ";
            }
            return indentationString;
        }

        private static readonly string PositionGroupHeaderText =
            i + "<!--" + Environment.NewLine
            + i + i + "Following attributes can be specified on PositionGroup:" + Environment.NewLine
            + i + i + i + "default - default position group that will be displayed in the UI" + Environment.NewLine
            + i + i + i + "tempo - 'Fastest', 'Median', 'Slowest'" + Environment.NewLine
            + i + i + i + "data - 'time', 'speed'" + Environment.NewLine
            + i + i + i + "stopped - 'true', 'false'" + Environment.NewLine
            + i + i + i + "hideblankcolumnsandrows - 'true', 'false' -->";

        //private static readonly string ToolTipText =
        //    i + "<!--" + Environment.NewLine
        //    + i + i + "Tooltip information, the following values are allowed:" + Environment.NewLine
        //    + i + i + i + "time, avgspeed, starttime, name, distance, elevation" + Environment.NewLine
        //    + i + i +
        //    ":NN   where NN is a number to indicate padding right (spaces), this is optionally for every value -->";

        internal static readonly string DefaultPreferencesXmlContent =
            "<?xml version='1.0' encoding='utf-8'?>"
            +
            "<MatrixPlugin xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
            + PositionGroupHeaderText
            + "  <Positions default='work standard' tempo='Median' data='time'>"
            + "    <!-- Add on or more PositionGroup. Each PositionGroup can have unlimited numbers of Point -->"
            + "    <!--   <Point name='Bryn'     lat='59.9203' lon='10.4893' /> -->"
            +
            "    <!-- PositionGroups can also be stored in .XML files in the same folder as this preference.xml file -->"
            + "  </Positions>"
            + "</MatrixPlugin>";

        internal static void CreateExamplePositionGroupXmls()
        {
            string exampleXmlHeader = "<?xml version='1.0' encoding='utf-8'?>" + Environment.NewLine
                                      + i + "<!--" + Environment.NewLine
                                      + i + i + "The following attributes can be specified on the PositionGroup:"
                                      + i + i + i + "tempo, data, stopped, hideblankcolumnsandrows" + Environment.NewLine
                                      + i + i +
                                      "(see preferences.xml or documentation for valid values for the attributes)" + Environment.NewLine
                                      + i + i +
                                      "(specified values on the attributes overrides value set in preferences.xml)" + Environment.NewLine
                                      + i + " -->" + Environment.NewLine;

            XmlDocument xml = new XmlDocument();
            xml.LoadXml(exampleXmlHeader
                        + "<PositionGroup name='work standard' tempo='Median'>"
                        + "  <Point name='Bryn'     lat='59.9203' lon='10.4893' />"
                        + "  <Point name='Kirkerud' lat='59.9025679' lon='10.4923296' />"
                        + "  <Point name='Sandvika' lat='59.8923' lon='10.5217' />"
                        + "  <Point name='DNV'      lat='59.8881' lon='10.5650' />"
                        + "</PositionGroup>");
            FileUtility.WriteXmlFile(Preferences.FilePath + "example1.xml", xml);

            xml.LoadXml(exampleXmlHeader
                        + "<PositionGroup name='work hill' data='speed'>"
                        + "  <Point name='Bryn'     lat='59.9203' lon='10.4893' />"
                        + "  <Point name='Bærums Verk' lat='59.9413204' lon='10.5026293' />"
                        + "  <Point name='Haslum'      lat='59.9121809' lon='10.5627108' />"
                        + "  <Point name='DNV'         lat='59.8881' lon='10.5650' />"
                        + "</PositionGroup>");
            FileUtility.WriteXmlFile(Preferences.FilePath + "example2.xml", xml);

            xml.LoadXml(exampleXmlHeader
                        + "<PositionGroup name='basis' stopped='true' tempo='Fastest' data='speed'>"
                        +
                        "  <!-- Latitude and longitudes must be in decimal degress. In Google Earth (Options, Show Lat/Long: Decimal Degress) -->"
                        + "  <Point name='Bryn'     lat='59.9203' lon='10.4893' />"
                        + "  <Point name='DNV'      lat='59.8881' lon='10.5650' />"
                        + "</PositionGroup>");
            FileUtility.WriteXmlFile(Preferences.FilePath + "example3.xml", xml);
        }
    }
}